package jdbctest;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Created by Administrator on 2017/9/11.
 */
//功能，把加载驱动与数据库连接封装起来
public class ConnectionUtils {
    //
    public static Connection getConnection(){
        //1.加载驱动

        //2.连接数据库
        //需要三个参数(URL/用户名/密码)
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3307/test", "root", "123456");
            return  conn;
            }
            catch (Exception e) {
            e.printStackTrace();
        }
        return null;

    }
}
